package com.wcgksoft.entity.system;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.wcgksoft.entity.dataAnalysis.DepartProjectData;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;

/**
 * @author 蒋世维
 * <p>
 * 项目名称：wisdom
 * 类名称：DepartProject
 * 类描述：项目信息
 * 创建人：jiangshiwei
 * 创建时间：2019-03-20 AM08:46:29
 * 修改备注：
 * @version 1.0.0
 */
@Entity
@Table(name = "Sys_Enterprise_project")
public class EnterpriseProject {


  public EnterpriseProject() {

  }

  public EnterpriseProject(Integer id) {
    this.id = id;
  }

  @Id
  @Basic(optional = false)
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  @Column(name = "id", nullable = false)
  private Integer id;

  /**
   * 企业
   */
  @ManyToOne(fetch = FetchType.EAGER)
  @JoinColumn(name = "enterprise_id")
  @Cascade({org.hibernate.annotations.CascadeType.REFRESH})
  private Enterprise enterprise;


  /**
   * 项目名称
   */
  @Column(name = "project_name", length = 100)
  private String projectName;
  /**
   * 城市
   */

  @Column(name = "city", length = 100)
  private String city;
  /**
   * 项目经理名字
   */
  @Column(name = "managername", length = 100)
  private String managername;

  /**
   * 联系方式
   */
  @Column(name = "contact", length = 100)
  private String contact;


  /**
   * 创建时间
   */
  @Column(name = "create_date")
  private Date createDate;

  /**
   * 开始时间
   */
  @Column(name = "opentime")
  private Date opentime;

  /**
   * 结束时间
   */
  @Column(name = "endtime")
  private Date endtime;


  /**
   * 备注
   */
  @Column(name = "remks")
  private String remks;

  /*
  可见片区
  */
  @JsonIgnore
  @ManyToMany(mappedBy = "enterpriseProjects", cascade = CascadeType.REFRESH, fetch = FetchType.EAGER)
  @Fetch(FetchMode.SUBSELECT)
  private Set<SysUser> sysBaseUsers;


  /**
   * 是项目0 或 片区 1
   */
  @Column(name = "is_pro_area")
  private Integer isProArea;

  /**
   * 上级id
   */
  @Column(name = "parent_id")
  private Integer parentId;


  @Transient
  private List<DepartProjectData> departProjectData=new ArrayList<>();

  public List<DepartProjectData> getDepartProjectData() {
    return departProjectData;
  }

  public void setDepartProjectData(List<DepartProjectData> departProjectData) {
    this.departProjectData = departProjectData;
  }


  public Integer getId() {
    return id;
  }

  public void setId(Integer id) {
    this.id = id;
  }

  public String getProjectName() {
    return projectName;
  }

  public void setProjectName(String projectName) {
    this.projectName = projectName;
  }

  public Date getCreateDate() {
    return createDate;
  }

  public void setCreateDate(Date createDate) {
    this.createDate = createDate;
  }

  public Enterprise getEnterprise() {
    return enterprise;
  }

  public void setEnterprise(Enterprise enterprise) {
    this.enterprise = enterprise;
  }

  public String getRemks() {
    return remks;
  }

  public void setRemks(String remks) {
    this.remks = remks;
  }

  public String getCity() {
    return city;
  }

  public void setCity(String city) {
    this.city = city;
  }

  public String getManagername() {
    return managername;
  }

  public void setManagername(String managername) {
    this.managername = managername;
  }

  public String getContact() {
    return contact;
  }

  public void setContact(String contact) {
    this.contact = contact;
  }

  public Date getOpentime() {
    return opentime;
  }

  public void setOpentime(Date opentime) {
    this.opentime = opentime;
  }

  public Date getEndtime() {
    return endtime;
  }

  public void setEndtime(Date endtime) {
    this.endtime = endtime;
  }

  public Set<SysUser> getSysBaseUsers() {
    return sysBaseUsers;
  }

  public void setSysBaseUsers(Set<SysUser> sysBaseUsers) {
    this.sysBaseUsers = sysBaseUsers;
  }

  public Integer getIsProArea() {
    return isProArea;
  }

  public void setIsProArea(Integer isProArea) {
    this.isProArea = isProArea;
  }

  public Integer getParentId() {
    return parentId;
  }

  public void setParentId(Integer parentId) {
    this.parentId = parentId;
  }
}
